var can1;
var ctx1;

var can2;
var ctx2;

var lastTime;   //上一帧的时间
var deltaTime;   //两帧的时间差

var canWidth;   //画布宽度
var canHeight;

var ane;    //海葵
var fruit;  //果实
var mom;

var bgPic = new Image();   //背景图片

document.body.onload=game;

function game() {
	init();
	lastTime = Date.now();
	deltaTime = 0;
	gameloop();
}

function init() {
	can1 = document.getElementById("canvas1");  //fish, dust,UI,circle
	ctx1 = can1.getContext("2d");
	can2 = document.getElementById("canvas2");  //background,fruit,haikui
	ctx2 = can2.getContext("2d");
	//加载背景图片
	bgPic.src="./src/11.png"; 
	//画布宽高
	canWidth = can1.width;
	canHeight = can1.height;

	

	fruit = new fruitObj();
	fruit.init();

	mom = new momObj();
	mom.init();

}
var num = 0;
var flag = true;
function gameloop() {
	window.requestAnimFrame(gameloop);
	//获取两帧时间差
	var now = Date.now();
	deltaTime = now - lastTime;
	lastTime = now;

	drawBackground();
	fruitMonitor();
	fruit.draw();

	ctx1.clearRect(0,0,canWidth,canHeight);
	mom.draw();
}

function stop(){
	var st = window.requestAnimFrame(stop);
	mom.number(st);	
	momFruiltCollision(st);
	// window.cancelAnimationFrame(st);
}

// $(".allcanvas").click(function(){
// 	$(".cover").show();
// 	stop();
// })


$(".r_close").click(function(){
	window.location.href = "stop.html";
})

$(".one").click(function(){
	$(".result").show();
	$(".gift").show();
})

$(".two").click(function(){
	$(".result").show();
	$(".no_invite").show();
})

$(".one_more").click(function(){
	$(".result").show();
	$(".no_invite").hide();
	$(".word").show();
})

